/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Logica;
import java.io.*;
import java.util.*;

public class Operaciones 
{
    private ArrayList al = new ArrayList();
    private int c;
    
    public void obtenerDato(){
 
        try{
        	FileReader hoja = new FileReader("/Users/Andrea/Desktop/taller.txt");
		BufferedReader lector = new BufferedReader(hoja);
	
                while(lector.ready()){  
                    al.add(Integer.parseInt(lector.readLine()));
                 }
                 c=al.size();
                    
         }catch(Exception k){
                k.getMessage();
	}
    }

    public void insertarDato(int x, int y){
        BufferedWriter escritor = null;
        
        try {
            escritor = new BufferedWriter(new FileWriter("/Users/Andrea/Desktop/taller.txt", true));
            escritor.newLine();
            escritor.write(""+x);
            escritor.newLine();
            escritor.write(""+y);
            escritor.close();
        } catch (Exception e){
            e.getMessage();
        }
        obtenerDato();
    }
     
    public float promedio(){
        float res=0;           
        for(int i= 0; i< al.size();i++){
            res = res+ Integer.parseInt(""+al.get(i));
        }
        res = res/al.size();
        return res;
    }
    
    public int suma(){
        int res=0;
        for(int i= 0; i< al.size();i++)
        {
            res = res+Integer.parseInt(""+ al.get(i));
        }
        return res;
    }
    
    public int valormax(){
        int val=0;
        for(int i= 0; i< al.size();i++)
        {
            if(Integer.parseInt(""+al.get(i)) > val){
                val=Integer.parseInt(""+al.get(i));
            }
        }
        return val;
    }
    
    public ArrayList getal(){
        return al;
    }
    
    public void setAl(ArrayList a){
        al= a;
    }
}
